package com.uam.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.uam.db.mapper.DataLayerMapper;
import com.uam.db.model.entity.DataLayer;
import com.uam.service.IDataLayerService;
import com.uam.utils.Convert;
import com.uam.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.crypto.Data;
import java.util.List;

/**
 * 图层记录Service业务层处理
 *
 * @author uam
 * @date 2023-11-23
 */
@Service
public class DataLayerServiceImpl implements IDataLayerService {
    @Autowired
    private DataLayerMapper dataLayerMapper;

    /**
     * 查询图层记录
     *
     * @param id 图层记录主键
     * @return 图层记录
     */
    @Override
    public DataLayer selectDataLayerById(Long id) {
        return dataLayerMapper.selectDataLayerById(id);
    }

    /**
     * 查询图层记录列表
     *
     * @param dataLayer 图层记录
     * @return 图层记录
     */
    @Override
    public IPage<DataLayer> selectDataLayerList(Page<DataLayer> page, DataLayer dataLayer) {
        return dataLayerMapper.selectDataLayerList(page, dataLayer);
    }

    /**
     * 新增图层记录
     *
     * @param dataLayer 图层记录
     * @return 结果
     */
    @Override
    public int insertDataLayer(DataLayer dataLayer) {
        dataLayer.setCreateTime(DateUtils.getNowDate());
        return dataLayerMapper.insertDataLayer(dataLayer);
    }

    /**
     * 修改图层记录
     *
     * @param dataLayer 图层记录
     * @return 结果
     */
    @Override
    public int updateDataLayer(DataLayer dataLayer) {
        dataLayer.setUpdateTime(DateUtils.getNowDate());
        return dataLayerMapper.updateDataLayer(dataLayer);
    }

    /**
     * 批量删除图层记录
     *
     * @param ids 需要删除的图层记录主键
     * @return 结果
     */
    @Override
    public int deleteDataLayerByIds(String ids) {
        return dataLayerMapper.deleteDataLayerByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除图层记录信息
     *
     * @param id 图层记录主键
     * @return 结果
     */
    @Override
    public int deleteDataLayerById(Long id) {
        return dataLayerMapper.deleteDataLayerById(id);
    }
}
